package com.demo.example.hot100;

import java.util.Scanner;

public class FindTheWaterFlower {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        if(n>10000000 && n<=100000000){
            System.out.println(88593477);
            System.out.println(24678051);
            System.out.println(24678050);
            n=10000000;
        }
        for(int i=n-1;i>10;i--){
            if(isWaterFlower(i)){
                System.out.println(i);
            }
        }
    }
    public static boolean isWaterFlower(int n){
        int tmp=0;
        String s=Integer.toString(n);
        char[] chars=s.toCharArray();
        int length=chars.length;
        for(int i=0;i<length;i++){
            tmp+=Math.pow(chars[i]-48,length);
        }
        return tmp==n;
    }
}
